package com.cqeec.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.cqeec.model.Particular;
import com.cqeec.util.JdbcUtil;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;

/**
 * 套餐插入数据库操作
 * @author 邓学强
 *   
 */
public class InsertedDao {
	/**
	 * 
	 * @param con 数据库连接
	 * @param particular 套餐详细实体
	 * @return 1表示添加成功 0表示失败
	 */
	 public  int inserted(Connection con,Particular particular){
		 //表需要修改为对应表
		 String sql="insert into particular value(?,?,?,?)";
		 try {
			con=JdbcUtil.getcon();
			PreparedStatement pstm=(PreparedStatement) con.prepareStatement(sql);
			pstm.setString(1,particular.getNumber());
			pstm.setString(2,particular.getPackage_name());
			pstm.setString(3,particular.getPackage_descriptior());
			pstm.setString(4,particular.getPrice());
			 int rs= pstm.executeUpdate();
			 //添加成功返回 1
			 if(rs!=0) {
				 return 1;
			 }
			 else {
				 return 0;
			 }
			
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 
		 
		 
		 
		 
		return 0;
		 
	 }
}
